package nettyTest.nettyCallBack;

import java.lang.reflect.Proxy;

public class MessageSendExecutor {
	private static RpcServerLoader loader = RpcServerLoader.getInstance();

	public MessageSendExecutor() {
	}

	public MessageSendExecutor(String serverAddress, RpcSerializeProtocol serializeProtocol) {
		loader.load(serverAddress, serializeProtocol);
	}

	public static void setRpcServerLoader(String serverAddress, RpcSerializeProtocol serializeProtocol) {
		loader.load(serverAddress, serializeProtocol);
	}

	public void stop() {
		loader.unLoad();
	}

	public static <T> T execute(Class<T> rpcInterface) {
		return (T) Reflection.newProxy(rpcInterface, new MessageSendProxy<T>(rpcInterface));
	}
}
